package main


func lexicalOrder(n int) []int {
	ans := make([]int, 0, n)
    var dfs func(a int, b int)
	dfs = func(a int, b int) {
		if a + b > n {
			return
		}
		ans = append(ans, a + b)
		for i := 0; i <= 9; i++ {
			dfs((a + b) * 10, i)
		}
	}
	for i := 1; i <= 9; i++ {
		dfs(0, i)
	}
	return ans
}